package edu.pku.sei.transformation.engine;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import edu.pku.sei.modeler.model.core.MetaModelElement;

public class EngineExtraData extends MetaModelElement {
	public Map<String, String> values = new HashMap<String, String>();

	public EngineExtraData() {
	}

	@Override
	public String toString() {
		String s = "";
		for (Entry<String, String> value : values.entrySet()) {
			if (s.length() > 0)
				s += "&";
			s += value.getKey() + "=" + value.getValue();
		}
		return s;
	}

	public void parse(String s) {
		String[] all = s.split("&");
		for (String string : all) {
			int i = string.indexOf("=");
			if (i == -1)
				continue;
			String key = string.substring(0, i);
			String value = string.substring(i + 1);
			values.put(key, value);
		}
	}
}
